package com.servlet;

import com.yitiao.controller.MainPageController;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/")
public class DispatcherServlet extends HttpServlet {
    @Override
    /**
     * <h3>工厂模式</h3>
     * <p>简单工厂：不适合子类较多，if else 过多的情况</p>
     * <p>工程方法：将工厂下降到子类，每个子类都有一个工厂</p>
     * <p>抽象工厂：</p>
     */
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String path = req.getServletPath();
        if (path.equals("/main/page") && req.getMethod().equals("GET")) {
            new MainPageController().getMainPageInfo(req,resp);
        } else if (path.equals("/") && req.getMethod().equals("GET")) {

        }
    }
}
